const { keys } = Object


export let set_state = (state, action) => {          //修改

    let new_state = { ...state }
    for (let key of keys(action.payload)) {
        new_state[key] = action.payload[key]
    }
    return new_state;
}

export let reset_state = (state, action) => {        //检测数据类型重置

    let new_state = { ...state }
    for (let key of keys(new_state)) {

        if (new_state[key] instanceof Array) {
            new_state[key] = []
            continue
        }
        if (new_state[key] instanceof Object) new_state[key] = {};
        if (typeof new_state[key] == 'number') new_state[key] = '';
        if (typeof new_state[key] == 'string') new_state[key] = '';
    }
    return new_state;
}